package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.Order;
import top.tsyz.service.IOrderService;

import java.util.List;

/**
 * OrderController控制器
 */
@RestController
@RequestMapping("/api/orders")
@Api(tags = "Order管理接口")
public class OrderController {

    @Autowired
    private IOrderService iorderservice;

    @GetMapping("/list")
    @ApiOperation("获取所有Order")
    public List<Order> list() {
        return iorderservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取Order")
    public Order getById(@PathVariable Long id) {
        return iorderservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增Order")
    public boolean save(@RequestBody Order order) {
        return iorderservice.save(order);
    }

    @PutMapping
    @ApiOperation("更新Order")
    public boolean update(@RequestBody Order order) {
        return iorderservice.updateById(order);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除Order")
    public boolean delete(@PathVariable Long id) {
        return iorderservice.removeById(id);
    }
}
